"""
总览模块API路由
"""
from fastapi import APIRouter, Query
from app.core.response import create_response
from app.services.mock_data import mock_generator

router = APIRouter()


@router.get("", summary="获取总览数据")
async def get_overview():
    """
    获取系统总览数据,包含系统状态、实时统计、模型性能和近期告警
    """
    data = mock_generator.generate_overview_data()
    return create_response(data=data)


@router.get("/status", summary="获取系统状态")
async def get_system_status():
    """
    获取系统运行状态
    """
    data = mock_generator.generate_system_status()
    return create_response(data=data)


@router.get("/stats", summary="获取实时统计")
async def get_real_time_stats():
    """
    获取实时人流统计数据
    """
    data = mock_generator.generate_real_time_stats()
    return create_response(data=data)


@router.get("/performance", summary="获取模型性能")
async def get_model_performance():
    """
    获取所有模型的性能指标
    """
    data = mock_generator.generate_overview_data()["modelsPerformance"]
    return create_response(data=data)


@router.get("/alerts", summary="获取近期告警")
async def get_recent_alerts(limit: int = Query(default=10, ge=1, le=100, description="返回告警数量")):
    """
    获取近期告警信息

    Args:
        limit: 返回告警数量,默认10条
    """
    all_alerts = mock_generator.generate_overview_data()["recentAlerts"]
    data = all_alerts[:limit]
    return create_response(data=data)
